package com.hewang.helloandroid;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class ButtonActivity extends AppCompatActivity {
    private Button mBtn3;
    public  static final String TAG = "hewang-learn-android";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_button);
        mBtn3 = (Button) findViewById(R.id.btn_3);
        mBtn3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(ButtonActivity.this, "btn3被点击了", Toast.LENGTH_SHORT).show();
            }
        });
        Log.i(TAG, "onCreate: 系统创建Activity时触发");
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.i(TAG, "onStart: Activity将进入已启动的状态，并对用户可见, 此回调包含了Activity进入前台与用户进行互动之前的最后准备工作");
    }
    
    
    @Override
    protected void onResume() {
        super.onResume();
        Log.i(TAG, "onResume: 在Activity开始与用户互动之前调用此回调");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.i(TAG, "onPause: 当Activity失去焦点并进入'已暂停'状态时，系统就会调用onPause()");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.i(TAG, "onStop: 当Activity对用户不可再见时，系统会调用onStop");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.i(TAG, "onRestart: 当处于'已停止'状态的Activity即将重启时，系统将会调用此回调，此回调后面总是跟着onStart");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.i(TAG, "onDestroy: 系统会在销毁Activity之前调用此回调，此回调是Activity接受的最后一个回调");
    }

    public void showToast(View view) {
        Toast.makeText(this, "btn4被点击了", Toast.LENGTH_SHORT).show();
    }
}